-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🌱 fix TestClusterExtensionInstallReResolvesWhenNewCataloge2e test #1008
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1008 +/- ##
=======================================
Coverage 73.46% 73.46%
=======================================
Files 32 32
Lines 1986 1986
=======================================
Hits 1459 1459
Misses 368 368
Partials 159 159
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
09ff7f3
to
4065eb1
Compare
test/e2e/e2e_suite_test.go
Outdated
func patchTestCatalog(ctx context.Context, name string, newImageRef string) (*catalogd.ClusterCatalog, error) { | ||
// Fetch the existing ClusterCatalog | ||
catalog := &catalogd.ClusterCatalog{} | ||
err := c.Get(ctx, client.ObjectKey{Name: name}, catalog) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Update the ImageRef | ||
catalog.Spec.Source.Image.Ref = newImageRef | ||
|
||
// Patch the ClusterCatalog | ||
err = c.Update(ctx, catalog) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return catalog, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a valid test case (where we patch the spec of a ClusterCatalog), but it does not cover the case I had in mind (and a case I think we need to cover).
What I have in mind here specifically is that we need to prove that the polling behavior alone is enough to trigger an upgrade of a ClusterExtension. Forcing a change by changing the image in the ClusterCatalog spec is a side-effect foils the true intention of the test.
This "polling triggers an upgrade" test is one of the most important features of OLM, so we unfortunately can't "fake" it by touching the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my first approach as well. Unfortunately, I can't find a way to change the latest
image tag on a local registry. crane
does not allow to change tags on local registries, hence I took this approach. Let me know if you you think this is still a valid test or we can approach this issue with a different solution. @joelanford
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "polling triggers an upgrade" test is one of the most important features of OLM, so we unfortunately can't "fake" it my touching the spec.
How is this accomplished in the current version of OLM? The use of make/sh/kinako(spelling), to get things into the cluster, the go to run tests
, IMO blurs what is/isn't being tested, there aren't clear separation of duties in this model.
Correct me if I'm wrong, but I think you want an image loaded into the running cluster after the test has executed? Is that correct? Or do you just want this test to run longer to see if the polling
picks up the the image already in the registry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this accomplished in the current version of OLM?
I'm not sure
The use of make/sh/kinako(spelling), to get things into the cluster, the go to run tests, IMO blurs what is/isn't being tested, there aren't clear separation of duties in this model.
I agree that the number of moving parts is a problem. I'm fairly confident that if we wanted something a bit leaner, we could build all of this in Go.
- Code in go that runs during an e2e that deploys an image registry in the cluster.
- Client-go code that runs
kubectl port-forward
to give the e2e test a way to communicate with the registry. - go-containerregistry code to push images, move tags, etc.
Correct me if I'm wrong, but I think you want an image loaded into the running cluster after the test has executed? Is that correct?
No, I don't think that is sufficient because the polling behavior of catalogd queries a remote registry. kind load
would not make it visible to the polling process. What I'm after is $something that causes the digest of a tag to change mid way through the test. That could be one of:
- Pre-populating the registry with two catalog images as part of the setup, and then during the test re-tagging the second image over the first.
- Pushing the first image at
repo:tag
as part of the setup, and then pushing the second image at that samerepo:tag
during the test.
8df658c
to
15642b7
Compare
// Tag the image with the new tag | ||
baseImage := "localhost:30000/e2e/test-catalog:v1" | ||
var err error | ||
err = crane.Tag(baseImage, "latest", crane.Insecure) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "latest"
be parsed from the value of testLatestCatalogRefEnvVar
(instead of being hardcoded)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testLatestCatalogRefEnvVar
consist of the complete image path with latest tag. We just need to tag name and not the complete image name here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but if we change that environment variable value to use a different tag, we'd have to change all the hardcoded "latest"
references in the e2e code as well. If we parse the tag out of the reference, there's just the one source of truth (but also see my other comment about possibly refactoring the envvars).
t.Log("It resolves again when a new catalog is available") | ||
|
||
// Tag the image with the new tag | ||
baseImage := "localhost:30000/e2e/test-catalog:v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it just me or does it feel like there was some envvar sprawl before this PR, and this PR is making it more apparent with the addition of the second catalog image?
It somewhat feels like we should either:
- Completely get rid of the envvars and just hardcode the references in the e2e test code
- Take a more holistic look at the envvars used to carry image reference and take an opportunity to refactor/reduce
- For example, should we have LOCAL_REGISTRY_HOST and CLUSTER_REGISTRY_HOST, and then every single repo/image/tag we'd use would get its own envvar with a consistent naming convention?
}, pollDuration, pollInterval) | ||
|
||
// update tag on test-catalog image with v2 image | ||
t.Log("By creating an ClusterExtension catalog with the updated ClusterCatalog") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log message seems incorrecT?
t.Log("By creating an ClusterExtension catalog with the updated ClusterCatalog") | |
t.Log("By updating the catalog tag to point to the v2 catalog") |
75b2968
to
8ea854c
Compare
export LOCAL_REGISTRY_HOST := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000 | ||
export CLUSTER_REGISTRY_HOST := localhost:30000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what others think, but to me it is more logical to flip these. LOCAL for localhost
, CLUSTER for the service-based name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't call localhost
a host, this is the ENDPOINT
into the the cluster. It's really the external
callable address. Spitballing, because names are hard, but maybe CLUSTER_REGISTRY_INGRESS
?
I agree the svc:5000
address should be called CLUSTER
.
Makefile
Outdated
export V1_IMAGE_TAG := v1 | ||
export V2_IMAGE_TAG := v2 | ||
export LATEST_IMAGE_TAG := latest | ||
export CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/e2e/test-catalog:$(V1_IMAGE_TAG) | ||
export UPDATED_CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/e2e/test-catalog:$(V2_IMAGE_TAG) | ||
export LATEST_CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/e2e/test-catalog:$(LATEST_IMAGE_TAG) | ||
export CLUSTER_V1_CATALOG_IMG := $(CLUSTER_REGISTRY_HOST)/e2e/test-catalog:$(V1_IMAGE_TAG) | ||
export CLUSTER_V2_CATALOG_IMG := $(CLUSTER_REGISTRY_HOST)/e2e/test-catalog:$(V2_IMAGE_TAG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments here:
- I don't think we need envvars for every combo. Let's just concatenate.
- Let's pick a convention like
<repoName>_<imageName_<tag>
and use that. - I don't think we'll need a "latest" variant here anymore. The test that needs it can deal with pushing its own tag local to the test.
So I think all of this can boil down to:
export V1_IMAGE_TAG := v1 | |
export V2_IMAGE_TAG := v2 | |
export LATEST_IMAGE_TAG := latest | |
export CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/e2e/test-catalog:$(V1_IMAGE_TAG) | |
export UPDATED_CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/e2e/test-catalog:$(V2_IMAGE_TAG) | |
export LATEST_CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/e2e/test-catalog:$(LATEST_IMAGE_TAG) | |
export CLUSTER_V1_CATALOG_IMG := $(CLUSTER_REGISTRY_HOST)/e2e/test-catalog:$(V1_IMAGE_TAG) | |
export CLUSTER_V2_CATALOG_IMG := $(CLUSTER_REGISTRY_HOST)/e2e/test-catalog:$(V2_IMAGE_TAG) | |
export E2E_TESTCATALOG_V1 := e2e/testcatalog:v1 | |
export E2E_TESTCATALOG_V2 := e2e/testcatalog:v2 |
And then when we need to reference a fully-qualified image, we would just use, for example:
$(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we still need to export the cluster image as CLUSTER_V1_CATALOG_IMG := $(CLUSTER_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
in the makefile, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong @joelanford, but I think you want less
stuff in the Makefile, and more of the work
in the tests that need "additional" things. IE instead of exported vars, concatenate them in the go code? So it would be something like:
fmt.Sprintf("%s/%s", os.Getenv("LOCAL_REGISTRY_HOST"), os.Getenv("E2E_TEST_CATALOG_V1"))
Or did you mean something entirely different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What @acornett21 said. I think there may be at least one place in the Makefile where we have to build/push the image, and that needs the fully-qualifed image reference.
In that case, I'd concatenate them just right at the call site rather than making an extra variable to store the concatenation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been implemented now in the latest commit. Thanks
b805ce9
to
a9f83ce
Compare
export CLUSTER_REGISTRY_HOST := localhost:30000 | ||
export E2E_TEST_CATALOG_V1 := e2e/test-catalog:v1 | ||
export E2E_TEST_CATALOG_V2 := e2e/test-catalog:v2 | ||
export CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need CATALOG_IMG
variable anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/e2e/e2e_suite_test.go
Outdated
@@ -24,6 +25,7 @@ var ( | |||
const ( | |||
testCatalogRefEnvVar = "CATALOG_IMG" | |||
testCatalogName = "test-catalog" | |||
LatestImageTag = "latest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to export this? I'd suggest unexporting:
LatestImageTag = "latest" | |
latestImageTag = "latest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll hit this in a quick follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the changes in this PR itself
Signed-off-by: yashoza19 <yoza@redhat.com>
Description
build-push-e2e-catalog.sh
to allow building and pushing new catalog imagetest-catalog:v2
and resolves to a successful installfixes #945
Reviewer Checklist